Touch up a few last minor comments
authorAlex Crichton <alex@alexcrichton.com>
Thu, 19 Nov 2015 22:36:38 +0000 (14:36 -0800)
committerAlex Crichton <alex@alexcrichton.com>
Thu, 19 Nov 2015 22:36:38 +0000 (14:36 -0800)
src/bin/rustc.rs
src/bin/rustdoc.rs
src/cargo/lib.rs
src/cargo/util/config.rs
src/cargo/util/rustc.rs
tests/tests.rs

index f157d9976fd3a46db4ca210e7d82a9e947267386..7eb86717e3c17eaf7521890df458694bd42b080c 100644 (file)
@@ -67,7 +67,8 @@ pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
     try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet));
     try!(config.shell().set_color_config(options.flag_color.as_ref().map(|s| &s[..])));
 
-    let root = try!(find_root_manifest_for_wd(options.flag_manifest_path, config.cwd()));
+    let root = try!(find_root_manifest_for_wd(options.flag_manifest_path,
+                                              config.cwd()));
 
     let opts = CompileOptions {
         config: config,
index e62adc87fc56eacd5ae03dc41f52f09697257896..5a33cb120289d3d59bce364a5f9df1eddf539a48 100644 (file)
@@ -1,6 +1,6 @@
 use cargo::ops;
 use cargo::util::{CliResult, Config};
-use cargo::util::important_paths::{find_root_manifest_for_cwd};
+use cargo::util::important_paths::{find_root_manifest_for_wd};
 
 #[derive(RustcDecodable)]
 struct Options {
@@ -65,7 +65,8 @@ pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
     try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet));
     try!(config.shell().set_color_config(options.flag_color.as_ref().map(|s| &s[..])));
 
-    let root = try!(find_root_manifest_for_cwd(options.flag_manifest_path));
+    let root = try!(find_root_manifest_for_wd(options.flag_manifest_path,
+                                              config.cwd()));
 
     let mut doc_opts = ops::DocOptions {
         open_result: options.flag_open,
index 1c85c686b66ed4743e2ee9dc2b907fb88e1c20eb..3688e958e5baace447bc078e68e7c15cc9a7bd68 100644 (file)
@@ -97,10 +97,7 @@ fn process<V, F>(mut callback: F)
 {
     let mut config = None;
     let result = (|| {
-        let cwd = try!(env::current_dir().chain_error(|| {
-            human("couldn't get the current directory of the process")
-        }));
-        config = Some(try!(Config::new(shell(Verbose, Auto), cwd)));
+        config = Some(try!(Config::default()));
         let args: Vec<_> = try!(env::args_os().map(|s| {
             s.into_string().map_err(|s| {
                 human(format!("invalid unicode in argument: {:?}", s))
index 8b2b09efc1b50c874839bba4fdfc4ab12229003e..4fe7c8dddad62c0300ea7566dfd1005b0ac1eb27 100644 (file)
@@ -11,6 +11,7 @@ use std::path::{Path, PathBuf};
 
 use rustc_serialize::{Encodable,Encoder};
 use toml;
+use core::shell::{Verbosity, ColorConfig};
 use core::{MultiShell, Package};
 use util::{CargoResult, ChainError, Rustc, internal, human, paths};
 
@@ -31,12 +32,11 @@ pub struct Config {
 }
 
 impl Config {
-    pub fn new(shell: MultiShell, cwd: PathBuf) -> CargoResult<Config> {
+    pub fn new(shell: MultiShell,
+               cwd: PathBuf,
+               homedir: PathBuf) -> CargoResult<Config> {
         let mut cfg = Config {
-            home_path: try!(homedir(cwd.as_path()).chain_error(|| {
-                human("Cargo couldn't find your home directory. \
-                      This probably means that $HOME was not set.")
-            })),
+            home_path: homedir,
             shell: RefCell::new(shell),
             rustc_info: Rustc::blank(),
             cwd: cwd,
@@ -54,6 +54,18 @@ impl Config {
         Ok(cfg)
     }
 
+    pub fn default() -> CargoResult<Config> {
+        let shell = ::shell(Verbosity::Verbose, ColorConfig::Auto);
+        let cwd = try!(env::current_dir().chain_error(|| {
+            human("couldn't get the current directory of the process")
+        }));
+        let homedir = try!(homedir(&cwd).chain_error(|| {
+            human("Cargo couldn't find your home directory. \
+                  This probably means that $HOME was not set.")
+        }));
+        Config::new(shell, cwd, homedir)
+    }
+
     pub fn home(&self) -> &Path { &self.home_path }
 
     pub fn git_db_path(&self) -> PathBuf {
@@ -227,7 +239,7 @@ impl Config {
     }
 
     fn scrape_rustc_version(&mut self) -> CargoResult<()> {
-        self.rustc_info = try!(Rustc::new(&self.rustc, self.cwd()));
+        self.rustc_info = try!(Rustc::new(&self.rustc));
         Ok(())
     }
 
index 1ddc36db0d86bd2f9be33556ee0c48f458227db1..aedf6e19c67abfdf835f7bf9627a7444039a5d16 100644 (file)
@@ -14,9 +14,9 @@ impl Rustc {
     ///
     /// If successful this function returns a description of the compiler along
     /// with a list of its capabilities.
-    pub fn new<P: AsRef<Path>>(path: P, cwd: &Path) -> CargoResult<Rustc> {
+    pub fn new<P: AsRef<Path>>(path: P) -> CargoResult<Rustc> {
         let mut cmd = util::process(path.as_ref());
-        cmd.cwd(cwd).arg("-vV");
+        cmd.arg("-vV");
 
         let mut ret = Rustc::blank();
         let mut first = cmd.clone();
index d79e1d2a0de38d493c597fbbdfbfd27122293e1e..19aaf0afff038b9ddaf0de64b485564282092341 100644 (file)
@@ -65,7 +65,7 @@ mod test_cargo_verify_project;
 mod test_cargo_version;
 mod test_shell;
 
-thread_local!(static RUSTC: Rustc = Rustc::new("rustc", &support::cwd()).unwrap());
+thread_local!(static RUSTC: Rustc = Rustc::new("rustc").unwrap());
 
 fn rustc_host() -> String {
     RUSTC.with(|r| r.host.clone())